<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>新建套餐</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script src="${ctx}/rs/js/jquery.validate.min.js"></script>
<script src="${ctx}/rs/js/jquery.form.js" type="text/javascript"></script>
</head>
<body>
<form id="form1" class="form-horizontal" action="${ctx}/TblComboPlanInfo/save.htm" method="post" enctype="multipart/form-data">
      <div class="form-group">
        <label for="name" class="col-sm-2 control-label item ">广告方案：</label>
        <div class="col-sm-6  ">
          <input type="file" class="form-control " id="cfile" name="cfile" />
          <input type="hidden" class="form-control " id="planId" name="planId" value="${ planId}"/>
          <input type="hidden" class="form-control " id="planStatus" name="planStatus" value="3"/>
        </div>
        <span class="help-block col-sm-4" id="valierr" style="color:#FF9966">*</span>
      </div>
    <div class="form-group">
        <div class="col-sm-10 text-center pt15">
             <button type="button" class="btn btn-primary btn-lg srt-btn active mr30" onclick="valiSubmit()">发送</button>
             <button type="reset" class="btn btn-default btn-lg srt-btn active">重置</button>
        </div>
      </div>
   
</form>


<script type="text/javascript" src="${ctx}/rs/js/bootstrapQ.min.js"></script>
<script src="${ctx}/rs/js/messages_zh.min.js"></script>
<script type="text/javascript">
var form = $('#form1');
form.validate({
    rules: {
    	cfile: {
            required: true
        }
      },
      highlight: function(element) {
          $(element).closest('.form-group').removeClass('success').addClass('error');
      },
      success: function(element) {
          element.text('OK!').addClass('valid')
          .closest('.form-group').removeClass('error').addClass('success');
      }
});

function valiSubmit() {
    if (form.valid()) {
        var options = {
                dataType : "json",
                beforeSubmit : function() {
                    $(".unable").show();
                },
                success : function(result) {
                    if (!$('.unable').is(':hidden')) {
                        $(".unable").hide();
                    }
                    if (result) {
                        // 普通消息提示条
                        bootstrapQ.msg({
                            msg : '发布成功！',
                            type : 'success',
                            time : 2000
                        });
                        //触发隐藏确认的按钮，引用回调方法关闭窗口并刷新列表
                        $("button.bsok").click();
                    } else {
                        bootstrapQ.msg({
                            msg : '发布失败！',
                            type : 'danger',
                            time : 2000
                        });
                    }
                },
                error : function(result) {
                    if (!$('.unable').is(':hidden')) {
                        $(".unable").hide();
                    }
                    bootstrapQ.msg({
                        msg : '发布失败！',
                        type : 'danger',
                        time : 2000
                    });
                }
            };
            form.ajaxSubmit(options);
            return true;
        }
    }

</script>
</body>
</html>